package com.edu.controller;


import com.R;
import com.edu.entity.subject.OneSubject;
import com.edu.service.SubjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author testjava
 * @since 2021-06-16
 */
@RestController
@RequestMapping("/eduservice/subject")
@CrossOrigin
public class SubjectController {

	@Autowired
	private SubjectService subjectService;

	//添加课程分类
	@PostMapping("/addSubject")
	public R addSubject(MultipartFile file){
		//上传过来的excel文件

		subjectService.saveSubject(file,subjectService);

		return R.ok();
	}

	@GetMapping("/getAllSubject")
	public R getAllSubject(){

		List<OneSubject> list = subjectService.getAllOneTwoSubject();
		return R.ok().data("list",list);
	}
}

